import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { CrossMassacreServerData } from "../data/CrossMassacreServerData";
import { ObjCreate } from "../../common/ObjCreate";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTextFormat } from "../../../../common/GTextFormat";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class CrossMassacreServerRender
    
    export  class CrossMassacreServerRender extends CellRenderer
    {
        constructor()
        {
            super();
            this._textFormat = GlobalStyle.textFormat1;
            this.initStyle();
            this.mouseEnabled = true;
            this.mouseChildren = true;
            this.addEventListener(flash.events.MouseEvent.CLICK, this.clickHandler);
            return;
        }

        protected /* override */ mouseEventHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!(this._myData == null) && !this._myData.mouseEnabled) 
            {
                arg1.stopImmediatePropagation();
                return;
            }
            super.mouseEventHandler(arg1);
            return;
        }

        protected initStyle(): void
        {
            var loc1=new Object /* flash.geom.Rectangle */(2, 2, 56, 15);
            this.setStyle("upSkin", GlobalClass.getScaleBitmap(ImagesConst.ShortcutBtn_upSkin, loc1));
            this.setStyle("downSkin", GlobalClass.getScaleBitmap(ImagesConst.ShortcutBtn_overSkin, loc1));
            this.setStyle("overSkin", GlobalClass.getScaleBitmap(ImagesConst.ShortcutBtn_overSkin, loc1));
            this.setStyle("selectedDownSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonGreen_overSkin, loc1));
            this.setStyle("selectedOverSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonGreen_overSkin, loc1));
            this.setStyle("selectedUpSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonGreen_overSkin, loc1));
            this.setStyle("disabledSkin", GlobalClass.getScaleBitmap(ImagesConst.ShortcutBtn_disabledSkin, loc1));
            this.setStyle("textFormat", this._textFormat);
            this.setStyle("disabledTextFormat", this._textFormat);
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (!(this._myData == null) && this._myData.selected) 
            {
                super.selected = true;
            }
            return;
        }

        public /* override */ set enabled(arg1: Boolean)
        {
            super.enabled = arg1;
            if (!(this._myData == null) && !this._myData.selected) 
            {
                super.enabled = this._myData.enabled;
            }
            return;
        }

        public /* override */ set filters(arg1: Array<any>)
        {
            super.filters = arg1;
            if (this._myData != null) 
            {
                if (this._myData.selected) 
                {
                    super.filters = [FilterConst.glowFilter];
                }
                else 
                {
                    super.filters = [];
                }
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            this._myData = arg1 as CrossMassacreServerData;
            if (this._myData.selected) 
            {
                this.enabled = true;
                this.selected = true;
                this.filters = [FilterConst.glowFilter];
            }
            else 
            {
                this.selected = false;
                this.enabled = this._myData.enabled;
                this.filters = [];
            }
            this.mouseEnabled = this._myData.mouseEnabled;
            this.mouseChildren = this._myData.mouseEnabled;
            this.selected = true;
            if (this._txt == null) 
            {
                loc1 = GlobalStyle.textFormat6;
                this._txt = ObjCreate.createGTextField("", 16, 2, 220, 15, this, loc1);
            }
            this._txt.text = this._myData.toString();
            this.drawNow();
            return;
        }

        /* internal  */clickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this.enabled) 
            {
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossMassacreSelectServerReq, this._myData));
            return;
        }

        /* internal */ /* var */_textFormat: GTextFormat;

        /* internal */ /* var */_myData: CrossMassacreServerData;

        /* internal */ /* var */_txt: GTextFiled;
    }
